package com.ruoyi.admin.service.impl;

import com.ruoyi.admin.domain.EventDictVO;
import com.ruoyi.admin.mapper.EventDetailMapper;
import com.ruoyi.admin.service.IEventDetailService;
import com.ruoyi.common.core.domain.entity.EventDetail;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 活动录入Service业务层处理
 * 
 * @author xukai
 * @date 2024-12-16
 */
@Service
public class EventDetailServiceImpl implements IEventDetailService 
{
    @Autowired
    private EventDetailMapper eventDetailMapper;

    /**
     * 查询活动录入
     * 
     * @param id 活动录入主键
     * @return 活动录入
     */
    @Override
    public EventDetail selectEventDetailById(Long id)
    {
        return eventDetailMapper.selectEventDetailById(id);
    }

    /**
     * 查询活动录入列表
     * 
     * @param eventDetail 活动录入
     * @return 活动录入
     */
    @Override
    public List<EventDetail> selectEventDetailList(EventDetail eventDetail)
    {
        return eventDetailMapper.selectEventDetailList(eventDetail);
    }

    /**
     * 新增活动录入
     * 
     * @param eventDetail 活动录入
     * @return 结果
     */
    @Override
    public int insertEventDetail(EventDetail eventDetail)
    {
        String createAccount = SecurityUtils.getUsername();
        eventDetail.setPublisher(createAccount);
        eventDetail.setCreatedAt(new Date());
        eventDetail.setUpdatedAt(new Date());
        eventDetail.setRemain(eventDetail.getQuota());
        eventDetail.setIsShow(true);
        eventDetail.setIsDeleted(0L);
        return eventDetailMapper.insertEventDetail(eventDetail);
    }

    /**
     * 修改活动录入
     * 
     * @param eventDetail 活动录入
     * @return 结果
     */
    @Override
    public int updateEventDetail(EventDetail eventDetail)
    {
        return eventDetailMapper.updateEventDetail(eventDetail);
    }

    /**
     * 批量删除活动录入
     * 
     * @param ids 需要删除的活动录入主键
     * @return 结果
     */
    @Override
    public int deleteEventDetailByIds(Long[] ids)
    {
        return eventDetailMapper.deleteEventDetailByIds(ids);
    }

    /**
     * 删除活动录入信息
     * 
     * @param id 活动录入主键
     * @return 结果
     */
    @Override
    public int deleteEventDetailById(Long id)
    {
        return eventDetailMapper.deleteEventDetailById(id);
    }

    @Override
    public List<EventDictVO> eventDict() {
        return eventDetailMapper.getEventDict();
    }

    @Override
    public int changeShow(EventDetail eventDetail) {
        return eventDetailMapper.eventDetail(eventDetail);
    }
}
